package com.mszlu.news.controller;

import com.mszlu.news.service.LoginService;
import com.mszlu.news.vo.Result;
import com.mszlu.news.vo.params.LoginParam;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Api(tags = "注册接口")
@RestController
@RequestMapping("register")
public class RegisterController {

    @Autowired
    private LoginService loginService;

    @PostMapping
    public Result register(@RequestBody LoginParam loginParam,HttpSession session){
        //sso 单点登录，后期如果把登录注册功能 提出去（单独的服务，可以独立提供接口服务）
        return loginService.register(loginParam,session);
    }

    @PostMapping("/sendEmail")
    @ResponseBody
    public Result sendEmail(String email, HttpServletRequest request){
        return loginService.sendMimeMail(email, request);
    }
}
